package com.itheima.chap04;

public class MathUtil {

    public static final double STRAINT_ANGLE = 180;

    public static final double DEGREES_TO_RADIANS = Math.PI / STRAINT_ANGLE;
    public static final double RADIANS_TO_DEGREES = STRAINT_ANGLE / Math.PI;
    /*静态变量，在类加载那一刻时直接赋值，只做一次运算*/
    public static double toRadians(double degrees)
    {
//        return degrees * Math.PI / STRAINT_ANGLE;
        return degrees * DEGREES_TO_RADIANS;
    }

    public static double toDegrees(double radians)
    {
//        return radians * STRAINT_ANGLE / Math.PI;
        return radians * RADIANS_TO_DEGREES;
    }
}

// 工具类就是用来封装某一非业务领域内一些通用的公共方法的类
// 也由于这些方法不需要用到实例变量，仅仅是作为工具方法使用，所以这些方法一般都是静态方法